package xin.clips.system.service.impl;


import xin.clips.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xin.clips.common.core.text.Convert;
import xin.clips.system.domain.gy.GyDeviceAlarmRecord;
import xin.clips.system.mapper.gy.GyDeviceAlarmRecordMapper;
import xin.clips.system.service.gy.IGyDeviceAlarmRecordService;

import java.util.List;

/**
 * 设备告警记录Service业务层处理
 *
 * @author clips
 * @date 2023-03-15
 */
@Service
public class GyDeviceAlarmRecordServiceImpl implements IGyDeviceAlarmRecordService {
    @Autowired
    private GyDeviceAlarmRecordMapper gyDeviceAlarmRecordMapper;

    /**
     * 查询设备告警记录
     *
     * @param alarmId 设备告警记录主键
     * @return 设备告警记录
     */
    @Override
    public GyDeviceAlarmRecord selectGyDeviceAlarmRecordByAlarmId(Long alarmId) {
        return gyDeviceAlarmRecordMapper.selectGyDeviceAlarmRecordByAlarmId(alarmId);
    }

    /**
     * 查询设备告警记录列表
     *
     * @param gyDeviceAlarmRecord 设备告警记录
     * @return 设备告警记录
     */
    @Override
    public List<GyDeviceAlarmRecord> selectGyDeviceAlarmRecordList(GyDeviceAlarmRecord gyDeviceAlarmRecord) {
        return gyDeviceAlarmRecordMapper.selectGyDeviceAlarmRecordList(gyDeviceAlarmRecord);
    }

    /**
     * 新增设备告警记录
     *
     * @param gyDeviceAlarmRecord 设备告警记录
     * @return 结果
     */
    @Override
    public int insertGyDeviceAlarmRecord(GyDeviceAlarmRecord gyDeviceAlarmRecord) {
        gyDeviceAlarmRecord.setCreateTime(DateUtils.getNowDate());
        return gyDeviceAlarmRecordMapper.insertGyDeviceAlarmRecord(gyDeviceAlarmRecord);
    }

    /**
     * 修改设备告警记录
     *
     * @param gyDeviceAlarmRecord 设备告警记录
     * @return 结果
     */
    @Override
    public int updateGyDeviceAlarmRecord(GyDeviceAlarmRecord gyDeviceAlarmRecord) {
        gyDeviceAlarmRecord.setUpdateTime(DateUtils.getNowDate());
        return gyDeviceAlarmRecordMapper.updateGyDeviceAlarmRecord(gyDeviceAlarmRecord);
    }

    /**
     * 批量删除设备告警记录
     *
     * @param alarmIds 需要删除的设备告警记录主键
     * @return 结果
     */
    @Override
    public int deleteGyDeviceAlarmRecordByAlarmIds(String alarmIds) {
        return gyDeviceAlarmRecordMapper.deleteGyDeviceAlarmRecordByAlarmIds(Convert.toStrArray(alarmIds));
    }

    /**
     * 删除设备告警记录信息
     *
     * @param alarmId 设备告警记录主键
     * @return 结果
     */
    @Override
    public int deleteGyDeviceAlarmRecordByAlarmId(Long alarmId) {
        return gyDeviceAlarmRecordMapper.deleteGyDeviceAlarmRecordByAlarmId(alarmId);
    }

    /**
     * 查询设备告警记录列表
     *
     * @param gyDeviceAlarmRecord 设备告警记录
     * @return 设备告警记录集合
     */
    public List<GyDeviceAlarmRecord> selectGyDeviceAlarmRecordListLimit(GyDeviceAlarmRecord gyDeviceAlarmRecord) {
        return gyDeviceAlarmRecordMapper.selectGyDeviceAlarmRecordListLimit(gyDeviceAlarmRecord);
    }


    /**
     * 返回用户访问日志的总记录数
     *
     * @return 用户访问日志的总记录数
     */
    public int selectTotal() {
        return gyDeviceAlarmRecordMapper.selectTotal();
    }



    /**
     * 查询设备告警每日数据
     *
     * @param gyDeviceAlarmRecord 设备告警记录
     * @return 设备告警记录集合
     */
    public List<GyDeviceAlarmRecord> selectAlarmDayAnalyByTime(GyDeviceAlarmRecord gyDeviceAlarmRecord){
        return  gyDeviceAlarmRecordMapper.selectAlarmDayAnalyByTime(gyDeviceAlarmRecord);
    }


}
